﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace LabMS.Web
{
    public partial class coursetry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lbWeeks.Controls.Add(new LiteralControl("<table>"));
            for (int i = 0; i < 20; ++i)
            {
                if (i % 10 == 0)
                {
                    lbWeeks.Controls.Add(new LiteralControl("<tr>"));
                }
                CheckBox check = new CheckBox();
                check.ID = "chkWeek" + i.ToString();
                int iWeeks = i + 1;
                check.Text = "周" + iWeeks.ToString();
                lbWeeks.Controls.Add(new LiteralControl("<td>"));
                lbWeeks.Controls.Add(check);
                lbWeeks.Controls.Add(new LiteralControl("</td>"));

                if (i ==9 || i == 19)
                {
                    lbWeeks.Controls.Add(new LiteralControl("</tr>"));
                }
            }
            
            lbWeeks.Controls.Add(new LiteralControl("</table>"));


            lbDayAndClass.Controls.Add(new LiteralControl("<table>"));

            for (int i = 0; i < 8; ++i)
            {
                lbDayAndClass.Controls.Add(new LiteralControl("<tr>"));
                for (int j = 0; j < 13; ++j)
                {
                    if (j == 0 && i > 0)
                    {
                        lbDayAndClass.Controls.Add(new LiteralControl("<td>"));
                        lbDayAndClass.Controls.Add(new LiteralControl(GetWeekByInt(i))); ;
                        lbDayAndClass.Controls.Add(new LiteralControl("</td>"));
                    }
                    else if (j > 0 && i == 0)
                    {
                        lbDayAndClass.Controls.Add(new LiteralControl("<td>"));
                        lbDayAndClass.Controls.Add(new LiteralControl(GetChineseNubByInt(j))); ;
                        lbDayAndClass.Controls.Add(new LiteralControl("</td>"));
                    }
                    else if (j > 0 && i > 0)
                    {
                        CheckBox check = new CheckBox();
                        check.ID = "chkDay" + i.ToString() + "Class" + j.ToString();
                        lbDayAndClass.Controls.Add(new LiteralControl("<td>"));
                        lbDayAndClass.Controls.Add(check);
                        lbDayAndClass.Controls.Add(new LiteralControl("</td>"));
                    }
                    else
                    {
                        lbDayAndClass.Controls.Add(new LiteralControl("<td>"));
                        lbDayAndClass.Controls.Add(new LiteralControl("星期\\节次")); ;
                        lbDayAndClass.Controls.Add(new LiteralControl("</td>"));
                    }
                }
                lbDayAndClass.Controls.Add(new LiteralControl("</tr>"));
            }
            lbDayAndClass.Controls.Add(new LiteralControl("</table>"));
        }


        public string GetWeekByInt(int iweek)
        {
            if (iweek == 1)
            {
                return "星期一";
            }
            if (iweek == 2)
            {
                return "星期二";
            }
            if (iweek == 3)
            {
                return "星期三";
            }
            if (iweek == 4)
            {
                return "星期四";
            }
            if (iweek == 5)
            {
                return "星期五";
            }
            if (iweek == 6)
            {
                return "星期六";
            }
            if (iweek == 7)
            {
                return "星期日";
            }
            return "";
        }

        public string GetChineseNubByInt(int iNub)
        {
            if (iNub == 1)
            {
                return "一";
            }
            if (iNub == 2)
            {
                return "二";
            }
            if (iNub == 3)
            {
                return "三";
            }
            if (iNub == 4)
            {
                return "四";
            }
            if (iNub == 5)
            {
                return "五";
            }
            if (iNub == 6)
            {
                return "六";
            }
            if (iNub == 7)
            {
                return "七";
            }
            if (iNub == 8)
            {
                return "八";
            }
            if (iNub == 9)
            {
                return "九";
            }
            if (iNub == 10)
            {
                return "十";
            }
            if (iNub == 11)
            {
                return "十一";
            }
            if (iNub == 12)
            {
                return "十二";
            }
            return "";
        }
    }

    
}
